#include <iostream>

#include "Reactor.hpp"
#include "Socket.hpp"
#include "Accepter.hpp"

void Usage(char *procname)
{
    std::cerr << "Usage: %s port" << procname << std::endl;
}

int main(int argc, char *argv[])
{
    if(argc != 2)
    {
        Usage(argv[0]);
        exit(1);
    }
    Reactor srv;
    int port = atoi(argv[1]);
    Connection *listenconnection = ConntionFactory::BuildListenConnection(port, &srv, 
                                                    &Accepter::Accept, nullptr, nullptr);
    srv.AddConnection(listenconnection);
    srv.Loop();

    return 0;
}